In Unix-like computer , init (short for initialization) is the first process started during booting of the operating system. Init is a daemon process that continues running until the system is shut down. It is the direct or indirect parent process of all other processes and automatically adopts all orphan process. Init is started by the kernel during the booting process; a kernel panic will occur if the kernel is unable to start it or if it dies for any reason. Init is typically assigned process identifier 1.
In Unix systems such as System III and System V, the design of init has diverged from the functionality provided by the init in Research Unix and its BSD derivatives. Up until the early 2010s, most Linux distributions employed a traditional init that was somewhat compatible with System V, while some distributions such as Slackware Linux use BSD-style startup scripts, and other distributions such as Gentoo Linux have their own customized versions.
Since then, most distros have employed a more modern init system, with most employing the init provided by the systemd project. Some distros have elected to create their own SystemV-init compatible system, such as Gentoo Linux's OpenRC and Void Linux's runit. These projects typically include features originally not in SystemV's init, such as multi-threading or interactive init. Most modern init systems are also able to dynamically start, stop and enable services after boot with prompting by the user.
BSD init was, prior to 4.3BSD, the same as Research UNIX's init; in 4.3BSD, it added support for running a windowing system such as X on graphical terminals under the control of /etc/ttys. To remove the requirement to edit /etc/rc, BSD variants have long supported a site-specific /etc/rc.local file that is run in a sub-shell near the end of the boot sequence.
A fully modular system was introduced with NetBSD 1.5 and ported to FreeBSD 5.0, OpenBSD 4.9 and successors. This system executes scripts in the /etc/rc.d directory. Unlike System V's script ordering, which is derived from the filename of each script, this system uses explicit dependency tags placed within each script. The order in which scripts are executed is determined by the rcorder utility based on the requirements stated in these tags.
At any moment, a running System V is in one of the predetermined number of states, called . At least one runlevel is the normal operating state of the system; typically, other runlevels represent single-user mode (used for repairing a faulty system), system shutdown, and various other states. Switching from one runlevel to another causes a per-runlevel set of scripts to be run, which typically mount filesystems, start or stop daemons, start or stop the X Window System, shutdown the machine, etc.
Aside from these standard ones, Unix and Unix-like systems treat runlevels somewhat differently. The common denominator, the /etc/inittab file, defines what each configured runlevel does in a given system.
| AIX | 5 | |
| antiX | 2 | |
| Gentoo Linux | 3 | |
| HP-UX | 3 (console/server/multiuser) or 4 (graphical) | |
| Linux From Scratch | 3 | |
| Slackware Linux | 3 | |
| Solaris / illumos | 3 | |
| UNIX System V Releases 3.x, 4.x | 2 | |
| UnixWare 7.x | 3 |
On Linux distributions defaulting to runlevel 10 in the table on the right, runlevel 10 invokes a multiuser graphical environment running the X Window System, usually with a display manager like GDM or KDM. However, the Solaris and illumos operating systems typically reserve runlevel 10 to shut down and automatically power off the machine.
On most systems, all users can check the current runlevel with either the runlevel or who -r command. The superuser user typically changes the current runlevel by running the telinit or init commands. The /etc/inittab file sets the default runlevel with the :initdefault: entry.
On Unix systems, changing the runlevel is achieved by starting only the missing services (as each level defines only those that are started / stopped). For example, changing a system from runlevel 3 to 4 might only start the local X server. Going back to runlevel 3, it would be stopped again.
Various efforts have been made to replace the traditional init daemons to address this and other design problems, including:
, systemd has been adopted by most major Linux distributions.See Systemd#Adoption
|
|